<html>
<head>
<link type="text/css" rel="stylesheet" href="css/style.css">
<script src="js/jquery-1.4.2.min.js" type="text/javascript"></script>

<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Busca Carros Engine</title>

<script type="text/javascript">

$(function(){
	$("#enviar").click( function(){
		if ($.trim($("#modelo").val()) != ''){
	        $('#enviar').hide();
	        $("#load").append('<img src="img/loading.gif"  id="loading" />');
	        jQuery.ajax({
	                type: "POST",
	                url: "/search",
	                dataType:"html",
	                data:"modelo="+ $('#modelo').val(),
	                success:function(response){
	                               
	                  jQuery.ajax({
			                type: "POST",
			                url: "/extract",
			                dataType:"html",
			                data:"modelo="+ $('#modelo').val(),
			                success:function(response){
			                   location.href ='listResults.jsp';
			                },
			                error:function (xhr, ajaxOptions, thrownError){
			                    alert(xhr.status);
			                    alert(thrownError);
			                }    
			      	 });
	                },
	                error:function (xhr, ajaxOptions, thrownError){
	                    alert(xhr.status);
	                    alert(thrownError);
	                }    
	      	 });
      	 }
    });
});

</script>

</head>


<body>
<div align="center"><img class="displayCenter" src="img/car_small.png"></div>
<br>
<div align="center" >
	<div id="load" name="load">
		<input type="text" id="modelo" name="modelo" value="" size="15">
		<input id="enviar" name="enviar" type="submit" value="Buscar">
	</div>
</div>
</body>
</html>
